package com.ocom.srvpaccess.controller;

import com.ocom.common.constant.SrvpAccessDeviceUrl;
import com.ocom.common.entity.human.EntityPersonnelInfo;
import com.ocom.common.entity.master.EntityYkmCenterConfig;
import com.ocom.common.enums.MachEnum;
import com.ocom.common.resp.RespMachMessage;
import com.ocom.common.utils.RespUtilMach;
import com.ocom.srvpaccess.service.MjYkmService;
import com.ocom.srvpaccess.service.PersonnelInfoService;
import com.ocom.srvpaccess.service.YkmCenterConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TimingTaskController {

    @Autowired
    private YkmCenterConfigService ykmCenterConfigService;

    @Autowired
    private PersonnelInfoService personnelInfoService;

    @PostMapping(value = SrvpAccessDeviceUrl.URLP_ACCESSDEVICE_getMJMkm)
    public RespMachMessage getMJMkm(String hourTime){
        try {
            List<EntityYkmCenterConfig> entityMjYkmList=ykmCenterConfigService.selectHourTime(hourTime);
            if (entityMjYkmList.size()<=0){
                return RespUtilMach.error(MachEnum.NOT_SEARCH);
            }
            return RespUtilMach.success(entityMjYkmList);
        }catch (Exception e){
            e.printStackTrace();
            return RespUtilMach.error(MachEnum.ERR);
        }
    }

    @PostMapping(value = SrvpAccessDeviceUrl.URLP_ACCESSDEVICE_getPersonnelInfo)
    public RespMachMessage getPersonnelInfo(Long comId,Integer deviceNums){
        List<EntityPersonnelInfo> entityPersonnelInfos=personnelInfoService.selectGetPersonnelInfo(comId,deviceNums);
        if (entityPersonnelInfos.size()<=0){
            return RespUtilMach.error(MachEnum.NOT_SEARCH);
        }
        return RespUtilMach.success(entityPersonnelInfos);
    }
}
